package laya.util;

import java.util.*;
import java.text.*;

import org.apache.log4j.Logger;

public class StringUtils
{
	private static Logger log = Logger.getLogger(StringUtils.class);
	
	public static boolean isEmpty(Object src)
	{
		return (null == src || 0 == src.toString().length()); 
	}
	
	public static boolean isBlank(Object src)
	{
		return (null == src || 0 == src.toString().trim().length());
	}
	
	public static String trim(Object src)
	{
		if (null != src)
		{
			return src.toString().trim();
		}
		
		return "";
	}
	
	public static String decode(String src)
	{
		if (null == src)
		{
			return "";
		}
		
		try
		{
			return new String(src.getBytes("iso8859_1"), "gb2312");
		}
		catch(Exception e)
		{
			log.warn("Exception :", e);
		}
	
		return "";
	}
	
	public static String encode(String src)
	{
		if (null == src)
		{
			return "";
		}
		
		try
		{
			return new String(src.getBytes("gb2312"), "iso8859_1");
		}
		catch(Exception e)
		{
			log.warn("Exception :", e);
		}
	
		return "";
	}
}
